package com.lagou.user.service;

import com.lagou.dubbo.UserDubbo;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

@Service
public class UserDubboImpl implements UserDubbo {
    @Autowired
    private RedisTemplate<Object, Object> redisTemplate;

    @Override
    public boolean isRegister(String email) {
        //是否已注册，根据邮箱判断,true代表已经注册过，
        //false代表尚未注册
        Object obj = redisTemplate.opsForValue().get("user:" + email);
        if(obj == null){
            return false;
        }
        return true;
    }

    @Override
    public String login(String token) {
        //根据token查询⽤户登录邮箱接⼝
        Object obj = redisTemplate.opsForValue().get(token);
        if(obj != null){
            return obj.toString();
        }
        return "";
    }
}
